/**
 * $Id$ Copyright 2009-2012 Oak Pacific Interactive. All rights reserved.
 */
package com.shuqi.model.parse.parser;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

import com.shuqi.model.parse.HandlerBase;

/**
 * 
 * 
 * @author <a href="mailto:">yaozhen</a>
 * @version 2014-2-11下午7:45:47
 */
public class PasswordSettingParser extends HandlerBase {

    private PasswordSettingParserInfo info;

    @Override
    public void startDocument() throws SAXException {
        super.startDocument();
        info = new PasswordSettingParserInfo();
    }

    @Override
    public void startElement(String uri, String localName, String name, Attributes attrs)
            throws SAXException {
        if (localName.equals("serverinfo")) {
            try {
                info.resultCode = Integer.valueOf(isNull(attrs, "state"));
            } catch (Exception e) {
                e.printStackTrace();
            }
            info.message = isNull(attrs, "message");
        } else if (localName.equals("UserInfo")) {
            // try {
            // info.gender = Integer.valueOf(isNull(attrs, "gender"));
            // info.balance = Integer.valueOf(isNull(attrs, "balance"));
            // } catch (Exception e) {
            // e.printStackTrace();
            // }
            info.uid = isNull(attrs, "userId");
            // info.nickName = isNull(attrs, "nickName");
            info.session = isNull(attrs, "session");
        }
    }

    @Override
    public PasswordSettingParserInfo getParsedData() {
        return info;
    }


    public static class PasswordSettingParserInfo {

        public int resultCode;

        public String message;

        public String uid;

        public String nickName;

        public int gender;

        public int balance;

        public String session;
    }

}
